// /* eslint-disable */
// /* eslint-disable no-new */
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ACUI from './utils/acui.js';
import './utils/acui.flexible.js';

Vue.use(ACUI);

Vue.config.productionTip = false
Vue.prototype.$defConfig = App.config
// new Vue({
//   el: '#app',
//   router,
//   components: { App },
//   template: '<App/>'
// })
new Vue({
  router: router,
  render: v => v(App),
  created () {
    // console.log(this.$defConfig)
  }
}).$mount('#app')

let scrollTop = 0

router.beforeEach((route, redirect, next) => {
  var element = document.getElementById('scrollView')
  if (redirect.path === '/') {
    if(element != null){
      scrollTop = element.scrollTop
    }

  }
  router.options.routes.forEach(element => {
    if (element.name === route.name) {
      Vue.prototype.$customConfig = element.component.config
    }
  })
  document.title = 'ACUI Touch - ' + route.name
  next()
})

router.afterEach(route => {
  var element = document.getElementById('scrollView')
  if (route.path === '/') {
    Vue.nextTick(() => {
      if(element != null){
        element.scrollTop = scrollTop
      }
    })
  } else {
    if(element != null){
      element.scrollTop = 0
    }
  }
})
